Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
I keep getting an error in my terminal, "error address already in use :::5000"

I'm following a node.js crash course and I get to the part where we are creating a server, but for some reason every time I try to run node index which is my js file name I'm getting the error:

address already in use :::5000

I've looked through similar problems and tried to kill that specific port but nothing seems to work.

if (req.url === '/') {
  fs.readFile(
    path.join(__dirname, 'public', 'index.html'),
    (err, content) => {
      if (err) throw err;
      res.writeHead(200, { 'Content-Type': 'text/html' });
      res.end(content);
    }
  );
}

    
const PORT = process.env.PORT || 5000;

server.listen(PORT, () => console.log(`Server running on port ${PORT}`));
   node index 
    node:events:504
          throw er; // Unhandled 'error' event
          ^
    
    Error: listen EADDRINUSE: address already in use :::5000
        at Server.setupListenHandle [as _listen2] (node:net:1330:16)
        at listenInCluster (node:net:1378:12)
        at Server.listen (node:net:1465:7)
        at Object.<anonymous> (/Users/zacdistant/Documents/GUIDES AND TUTORIALS/Node JS Crash Course/index.js:91:8)
        at Module._compile (node:internal/modules/cjs/loader:1097:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
        at Module.load (node:internal/modules/cjs/loader:975:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
        at node:internal/main/run_main_module:17:47
    Emitted 'error' event on Server instance at:
        at emitErrorNT (node:net:1357:8)
        at processTicksAndRejections (node:internal/process/task_queues:83:21) {
      code: 'EADDRINUSE',
      errno: -48,
      syscall: 'listen',
      address: '::',
      port: 5000
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If you are on a Mac, port 5000 and 7000 are already used by the Control Center with the AirPlay reveicer:

lsof -i :5000                                                              
COMMAND   PID USER   FD   TYPE  DEVICE              SIZE/OFF NODE NAME
ControlCe 479 ****   26u  IPv4  0xa2d0e96b616f779d  0t0      TCP  *:commplex-main (LISTEN)
ControlCe 479 ****   27u  IPv6  0xa2d0e96693d0bc65  0t0      TCP  *:commplex-main (LISTEN)

To solve the issue you have to either change the port you use in your server like const PORT = process.env.PORT || 9000;, or turn off the AirPlay receiver. Also, if you want to check before hand is the port free, run netstat -anv -p tcp.

about 4 years ago · Juan Pablo Isaza Relatório

0

As @jamomani explained Mac uses port 5000 and 7000 that are used by the Control Center with the AirPlay receiver

To solve the issue you have to either change the port you use in your server like const PORT = process.env.PORT || 9000;, or turn off the AirPlay receiver. Also, if you want to check before hand is the port free, run netstat -anv -p tcp.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda